use replication.dta

/*Treatment variable: 3-yr or 12-mo horizon*/
gen yr3 = .
recode yr3 *=0 if JEN25A1~=.
recode yr3 *=1 if JEN25A2~=.
drop if yr3==.
la var yr3 "Time horizon"
la def yr3_l 1 "3-year horizon" 0 "12-month horizon"
la val yr3 yr3_l

/*Political variables: Vote intent and Presidential approval*/
gen voteint = PRES2012ROMS4
recode voteint 1=1 2=0 *=.
label variable voteint "Vote intent"
la def vote_l 1 "Obama" 0 "Romney"
la val voteint vote_l 

gen papprovalS3 = APPRPRESS3
recode papprovalS3 .=0
gen papprovalS4 = APPRPRESS4
recode papprovalS4 .=0
gen papproval = papprovalS3 + papprovalS4
recode papproval -1=. 0=. 5=. 1=4 2=3 3=2 4=1
label variable papproval "Presidential Approval, 4pt, high=approve"

/*political knowledge items*/
/*polknow_correct is the number of items the respondent got right*/
/*missing is treated as 0 unless all items were missing*/
gen polknow1s2 = 0
replace polknow1s2 = 1 if POLKNOW1S2 == 2
replace polknow1s2 = . if POLKNOW1S2 ==.
gen polknow2s2 = 0
replace polknow2s2 = 1 if POLKNOW2S2 == 4
replace polknow2s2 = . if POLKNOW2S2 ==.
gen polknow3s2 = 0
replace polknow3s2 = 1 if POLKNOW3S2 == 3
replace polknow3s2 = . if POLKNOW3S2 ==.
gen polknow5s2 = 0
replace polknow5s2 = 1 if POLKNOW5S2 == 2
replace polknow5s2 = . if POLKNOW5S2 ==.
gen polknow6s2 = 0
replace polknow6s2 = 1 if POLKNOW6S2 == 3
replace polknow6s2 = . if POLKNOW6S2 ==.
gen polknow7s2 = 0
replace polknow7s2 = 1 if POLKNOW7S2 == 2
replace polknow7s2 = . if POLKNOW7S2 ==.
gen polknow12s2 = 0
replace polknow12s2 = 1 if POLKNOW12S2 == 3
replace polknow12s2 = . if POLKNOW12S2 ==.
gen polknow13s2 = 0
replace polknow13s2 = 1 if POLKNOW13S2 == 1
replace polknow13s2 = . if POLKNOW13S2 ==.
gen polknow17s2 = 0
replace polknow17s2 = 1 if POLKNOW17S2 == 1
replace polknow17s2 = . if POLKNOW17S2 ==.

egen polknow_correct = rowtotal ( polknow1s2 polknow2s2 polknow3s2 polknow5s2 polknow6s2 polknow7s2 polknow12s2 polknow13s2 polknow17s2 ), missing

*Sophisticate dummy
gen sophisticate = polknow_correct
recode sophisticate 0/5=0 6/10=1 .=.

*High-income individual, dummy variable
gen hiincome = incomehhldsp
recode hiincome 1/6=0 7/17=1 -1/.=.

/*PID variables: democrat and republican dummies; presence of partisan id*/
gen democrat = PATRYID7PTSP
recode democrat 1/3=1 *=0
gen republican = PATRYID7PTSP
recode republican 5/7=1 *=0

gen partisan = .
replace partisan = 1 if PARTYID1SP == 1 | PARTYID1SP == 3
replace partisan = 0 if PARTYID1SP == 2

/*Economic evaluations over 12mo and 3yr frames*/
gen une12mo = .
recode une12mo *=0 if JEN25A1==2 
recode une12mo *=2 if JEN25A1A==1
recode une12mo *=1 if JEN25A1A==2
recode une12mo *=-2 if JEN25A1B==1
recode une12mo *=-1 if JEN25A1B==2
la var une12mo "Unemployment, 12-mo frame"
gen growth12mo = .
recode growth12mo *=0 if JEN26A1==2
recode growth12mo *=2 if JEN26A1A==1
recode growth12mo *=1 if JEN26A1A==2
recode growth12mo *=-2 if JEN26A1B==1
recode growth12mo *=-1 if JEN26A1B==2
la var growth12mo "Growth, 12-mo frame"
gen cp12mo = .
recode cp12mo *=0 if JEN27A1==2
recode cp12mo *=2 if JEN27A1A==1
recode cp12mo *=1 if JEN27A1A==2
recode cp12mo *=-2 if JEN27A1B==1
recode cp12mo *=-1 if JEN27A1B==2
la var cp12mo "Consumer Prices, 12-mo frame"
gen def12mo = .
recode def12mo *=0 if JEN28A1==2
recode def12mo *=2 if JEN28A1A==1
recode def12mo *=1 if JEN28A1A==2
recode def12mo *=-2 if JEN28A1B==1
recode def12mo *=-1 if JEN28A1B==2
la var def12mo "Budget Deficit, 12-mo frame"

gen une3yr = .
recode une3yr *=0 if JEN25A2==2
recode une3yr *=2 if JEN25A2A==1
recode une3yr *=1 if JEN25A2A==2
recode une3yr *=-2 if JEN25A2B==1
recode une3yr *=-1 if JEN25A2B==2
la var une12mo "Unemployment, 3-yr frame"
gen growth3yr = .
recode growth3yr *=0 if JEN26A2==2
recode growth3yr *=2 if JEN26A2A==1
recode growth3yr *=1 if JEN26A2A==2
recode growth3yr *=-2 if JEN26A2B==1
recode growth3yr *=-1 if JEN26A2B==2
la var growth12mo "Growth, 3-yr frame"
gen cp3yr = .
recode cp3yr *=0 if JEN27A2==2
recode cp3yr *=2 if JEN27A2A==1
recode cp3yr *=1 if JEN27A2A==2
recode cp3yr *=-2 if JEN27A2B==1
recode cp3yr *=-1 if JEN27A2B==2
la var cp12mo "Consumer Prices, 3-yr frame"
gen def3yr = .
recode def3yr *=0 if JEN28A2==2
recode def3yr *=2 if JEN28A2A==1
recode def3yr *=1 if JEN28A2A==2
recode def3yr *=-2 if JEN28A2B==1
recode def3yr *=-1 if JEN28A2B==2
la var def12mo "Budget Deficit, 3-yr frame"

la def econ_eval -2 "Decreased a lot" -1 "Decreased" 0 "Stayed same" 1 "Increased" 2 "Increased a lot"
la val une12mo une3yr growth12mo growth3yr cp12mo cp3yr def12mo def3yr econ_eval

*Merging economic evaluations, by indicator, into a single variable*/
gen uneret = 0
recode uneret *=-2 if une12mo==-2 | une3yr==-2 
recode uneret *=-1 if une12mo==-1 | une3yr==-1
recode uneret *=1 if une12mo==1 | une3yr==1
recode uneret *=2 if une12mo==2 | une3yr==2
gen growthret = 0
recode growthret *=-2 if growth12mo==-2 | growth3yr==-2 
recode growthret *=-1 if growth12mo==-1 | growth3yr==-1
recode growthret *=1 if growth12mo==1 | growth3yr==1
recode growthret *=2 if growth12mo==2 | growth3yr==2
gen cpret = 0
recode cpret *=-2 if cp12mo==-2 | cp3yr==-2 
recode cpret *=-1 if cp12mo==-1 | cp3yr==-1
recode cpret *=1 if cp12mo==1 | cp3yr==1
recode cpret *=2 if cp12mo==2 | cp3yr==2
gen defret = 0
recode defret *=-2 if def12mo==-2 | def3yr==-2 
recode defret *=-1 if def12mo==-1 | def3yr==-1
recode defret *=1 if def12mo==1 | def3yr==1
recode defret *=2 if def12mo==2 | def3yr==2

la var uneret "Unemployment, all frames"
la var growthret "Growth, all frames"
la var cpret "Consumer Prices, all frames"
la var defret "Budget Deficit, all frames"
la val *ret econ_eval

*Coding response correctness*
gen une_right = 0
recode une_right *=1 if une12mo==-1 | une12mo==-2 | une3yr==1 | une3yr==2
gen growth_right = 0
recode growth_right *=1 if growth12mo==1 | growth12mo==2 | growth3yr==1 | growth3yr==2
gen def_right = 0
recode def_right *=1 if def12mo==0 | def12mo==-1 | def3yr==2 | def3yr==1
gen cp_right = 0
recode cp_right *=1 if cp12mo==0 | cp12mo==1 | cp3yr==1 | cp3yr==2

********Treatment effects by demographics and PID******
ttest GENDERSP, by(yr3) /*1=M, 2=F*/
ttest agesp, by(yr3)
ttest RACE1SP, by(yr3) /*1=White, 0=Nonwhite*/
ttest PATRYID7PTSP, by(yr3) /*1=Dem, 7=Rep*/

*Table 2*
tab2 yr3 growth_right, row ch
tab2 yr3 une_right, row ch
tab2 yr3 cp_right, row ch
tab2 yr3 def_right, row ch

***Table 3***
ttest uneret, by(yr3)
ttest growthret, by(yr3)
ttest cpret, by(yr3)
ttest defret, by(yr3)

*Table 4*
logit voteint growthret yr3
logit voteint c.growthret##c.yr3
test yr3 c.growthret#c.yr3

logit voteint uneret yr3
logit voteint c.uneret##c.yr3
test yr3 c.uneret#c.yr3

logit voteint cpret yr3
logit voteint c.cpret##c.yr3
test c.cpret#c.yr3

logit voteint defret yr3
logit voteint c.defret##c.yr3
test c.defret#c.yr3

/*****Alternative models with presidential approval******
ologit papproval c.growthret##c.yr3
test yr3 c.growthret#c.yr3
ologit papproval c.uneret##c.yr3
test yr3 c.uneret#c.yr3
ologit papproval c.defret##c.yr3
test yr3 c.defret#c.yr3
ologit papproval c.cpret##c.yr3
test yr3 c.cpret#c.yr3*/

/*Table 5 M1*/
logit voteint growthret yr3
logit voteint growthret yr3 c.growthret#c.yr3
test yr3 c.growthret#c.yr3
test growthret c.growthret#c.yr3
gen growthxyr3 = c.growthret#c.yr3
quietly estsimp logit voteint growthret yr3 growthxyr3
setx growthret -.1271 yr3 0 growthxyr3 0
simqi
setx growthret -.1271 yr3 1 growthxyr3 -.1271
simqi
simqi, fd(pr) changex(yr3 0 1 growthxyr3 0 -.1271)
setx growthret 1 yr3 0 growthxyr3 0
simqi
setx growthret 2 yr3 1 growthxyr3 2
simqi
simqi, fd(pr) changex(growthret 1 2 yr3 0 1 growthxyr3 0 2)
drop b1 b2 b3 b4

/*Table 5 M2*/
logit voteint uneret yr3
logit voteint uneret yr3 c.uneret#c.yr3
test yr3 c.uneret#c.yr3
test uneret c.uneret#c.yr3
gen uneretxyr3 = c.uneret#c.yr3
quietly estsimp logit voteint uneret yr3 uneretxyr3
setx uneret .3029 yr3 0 uneretxyr3 0
simqi
setx uneret .3029 yr3 1 uneretxyr3 .3029
simqi
simqi, fd(pr) changex(yr3 0 1 uneretxyr3 0 .3029)
setx uneret 1 yr3 0 uneretxyr3 0
simqi
setx uneret -1 yr3 1 uneretxyr3 -1
simqi
simqi, fd(pr) changex(uneret 1 -1 yr3 0 1 uneretxyr3 0 -1) 
drop b1 b2 b3 b4

/*Table 5 M3*/
logit voteint cpret yr3
logit voteint cpret yr3 c.cpret#c.yr3
test yr3 c.cpret#c.yr3
test cpret c.cpret#c.yr3
gen cpretxyr3 = c.cpret#c.yr3
quietly estsimp logit voteint cpret yr3 cpretxyr3
setx cpret 1.353 yr3 0 cpretxyr3 0
simqi
setx cpret 1.353 yr3 0 cpretxyr3 1.353
simqi
simqi, fd(pr) changex(yr3 0 1 cpretxyr3 0 1.353)
setx cpret 1 yr3 0 cpretxyr3 0
simqi
setx cpret 2 yr3 1 cpretxyr3 0
simqi
simqi, fd(pr) changex(cpret -1 0 yr3 0 1 cpretxyr3 0 0)
simqi, fd(pr) changex(cpret -1 0 yr3 0 1 cpretxyr3 0 0) level (90)
drop b1 b2 b3 b4

/*Table 5 M4*/
logit voteint defret yr3
logit voteint defret yr3 c.defret#c.yr3
test yr3 c.defret#c.yr3
test defret c.defret#c.yr3
gen defretxyr3 = c.defret#c.yr3
quietly estsimp logit voteint defret yr3 defretxyr3
setx defret 1.352 yr3 0 defretxyr3 0
simqi
setx defret 1.352 yr3 1 defretxyr3 1.352
simqi
simqi, fd(pr) changex(yr3 0 1 defretxyr3 0 1.352)
setx defret -1 yr3 0 defretxyr3 0
simqi
setx defret 2 yr3 1 defretxyr3 2
simqi
simqi, fd(pr) changex(defret -1 2 yr3 0 1 defretxyr3 0 2)
drop b1 b2 b3 b4
